package hot100;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author aodre , QQ : 480029069
 * @date 2023/10/21 15:38
 */
public class lc75颜色分类 {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newSingleThreadExecutor();

    }

    // 荷兰国旗问题
    public void sortColors(int[] nums) {
        int l = -1, r = nums.length, index = 0;
        while(index < r){
            if(nums[index] < 1){
                swap(nums,++l,index++);
            }else if(nums[index] == 1){
                index++;
            }else{
                swap(nums,index,--r);
            }
        }
    }

    public void swap(int nums[],int i,int j){
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }

}
